<script setup lang="ts">
import {onMounted, ref} from "vue";
import router from "@/router/index.js";
import {User,Money,Box,Refrigerator,Flag,Odometer,Magnet,Position,Tools } from '@element-plus/icons-vue'


onMounted(()=>{
  onMounted(()=>{
    router.replace({path: '/home/manage'});
  })
})

// 菜单折叠，如果是true，菜单折叠，false，菜单展开
const isCollapse = ref(false)
const handleOpen = (key: string, keyPath: string[]) => {
  // console.log(key,keyPath)
  // console.log(key);
  // console.log(keyPath);



}
const handleClose = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}

const changPage=(e:string)=>{
  router.replace(e)
}



</script>

<template>
  <!-- 面包屑 -->
  <div class="bread-container">
    <el-breadcrumb separator=">">
      <el-breadcrumb-item :to="{ path: `/` }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>{{"后台管理"}}</el-breadcrumb-item>
    </el-breadcrumb>
  </div>
  <br>
  <div >
    <el-container  >
      <!--   menu 可以折叠，这里要配合el-aside的width, 绑定isCollapse值  -->
      <el-aside :width="isCollapse ? `64px`:`200px` " >
        <el-radio-group v-model="isCollapse" style="margin-bottom: 20px">
          <el-radio-button :value="false">展开</el-radio-button>
          <el-radio-button :value="true">折叠</el-radio-button>
        </el-radio-group>

        <el-menu
            default-active="/manage/userManager"
            class="el-menu-vertical-demo"
            :collapse="isCollapse"
            @open="handleOpen"
            @close="handleClose"
            @select="changPage"
            unique-opened="unique-opened"
        >




          <el-sub-menu index="3">
            <template #title>
              <el-icon><User /></el-icon>
              <span>用户管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/manage/userManager">用户后台管理</el-menu-item>
              <el-menu-item index="/manage/addUser">添加用户</el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>

          <el-sub-menu index="4">
            <template #title>
              <el-icon><Money /></el-icon>
              <span>项目管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/manage/projectManager">项目后台管理</el-menu-item>
              <el-menu-item index="/manage/addProject">添加项目</el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>

          <el-sub-menu index="5">
            <template #title>
              <el-icon><Box /></el-icon>
              <span>仓库管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/manage/warehouseManager">仓库管理</el-menu-item>
              <el-menu-item index="/manage/addWarehouse">添加仓库</el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>


          <el-sub-menu index="6">
            <template #title>
              <el-icon><Refrigerator /></el-icon>
              <span>仓库内部管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/manage/warehouseLayoutManager">仓库内部后台管理</el-menu-item>
              <el-menu-item index="/manage/addWarehouseLayout">添加仓库内部数据</el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>

          <el-sub-menu index="7">
            <template #title>
              <el-icon><Flag /></el-icon>
              <span>所在地管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/manage/locationManager">所在地管理</el-menu-item>
              <el-menu-item index="/manage/addLocation">添加所在地</el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>

          <el-sub-menu index="9">
            <template #title>
              <el-icon><Magnet /></el-icon>
              <span>材料类型管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/manage/materialTypeManager">材料类型管理</el-menu-item>
              <el-menu-item index="/manage/addMaterialType">添加材料类型</el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>


          <el-sub-menu index="2">
            <template #title>
              <el-icon><Tools /></el-icon>
              <span>设备类型管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/manage/equipTypeManager">设备类型管理</el-menu-item>
              <el-menu-item index="/manage/addEquipType">添加设备类型</el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>

          <el-sub-menu index="10">
            <template #title>
              <el-icon><Position /></el-icon>
              <span>材料盘点管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/manage/materialStockTake">材料盘点管理</el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>



        </el-menu>
      </el-aside>
      <el-main  ><router-view/></el-main>
    </el-container>
  </div>






</template>

<style scoped lang="scss">
.top-category {
  h3 {
    font-size: 28px;
    color: #666;
    font-weight: normal;
    text-align: center;
    line-height: 100px;
  }

  .sub-list {
    margin-top: 20px;
    background-color: #fff;

    ul {
      display: flex;
      padding: 0 32px;
      flex-wrap: wrap;

      li {
        width: 168px;
        height: 160px;


        a {
          text-align: center;
          display: block;
          font-size: 16px;

          img {
            width: 100px;
            height: 100px;
          }

          p {
            line-height: 40px;
          }

          &:hover {
            color: $xtxColor;
          }
        }
      }
    }
  }

  .ref-goods {
    background-color: #fff;
    margin-top: 20px;
    position: relative;

    .head {
      // .xtx-more {
      //   position: absolute;
      //   top: 20px;
      //   right: 20px;
      // }

      // .tag {
      //   text-align: center;
      //   color: #999;
      //   font-size: 20px;
      //   position: relative;
      //   top: -20px;
      // }
    }

    .body {
      display: flex;
      justify-content: space-around;
      padding: 0 40px 30px;
    }
  }

  .bread-container {
    padding: 25px 0;
  }
}

.home-banner {
  width: 1240px;
  height: 500px;
  margin: 0 auto;

  /* position: absolute;
  left: 0;
  top: 0;
  z-index: 98;
  */

  img {
    width: 100%;
    height: 500px;
  }
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 150px;
  min-height: 400px;
  font-size: small;
  margin-top: 10px;
  margin-buttom: 10px;

  --el-menu-item-height: 30px;
  --el-menu-sub-item-height: 30px;
  --el-menu-level-padding: 10px;
  --el-menu-base-level-padding: 10px;
}
/* 修改展开状态下 el-menu-item 之间的间距 */
.el-menu-vertical-demo:not(.el-menu--collapse) .el-menu-item {
  margin-top: 0; /* 可根据需求调整顶部间距 */
  margin-bottom: 3px; /* 可根据需求调整底部间距 */
  padding-top: 0;
  padding-bottom: 3px;
}

/* 修改折叠状态下 el-menu-item 之间的间距 */
.el-menu-vertical-demo.el-menu--collapse .el-menu-item {
  margin-top: 0; /* 可根据需求调整顶部间距 */
  margin-bottom: 0; /* 可根据需求调整底部间距 */
  padding-top: 0;
  padding-bottom: 0;
}




// 要想使得侧边栏高度是100，要用这个
.el-menu{
  height: 100vh;
}

.el-menu-item.is-active {
  background-color: #7a9be9 !important;
  color: #fff;
  span {
    color: #fff !important;
  }
}
</style>